import yaml from 'js-yaml'
import fs from 'node:fs'
import knex from 'knex'

const baseConfig = yaml.load(fs.readFileSync('./base.yaml', 'utf8'))

const db = knex({
  client: 'mysql2',
  connection: {
    host: baseConfig.host,
    port: baseConfig.port,
    user: baseConfig.user,
    password: baseConfig.password,
    database: baseConfig.database
  }
});

db.schema.createTable('list', (table) => {
  table.increments('id') //id自增
  table.integer('age') //age 整数
  table.string('name') //name 字符串
  table.string('hobby') //hobby 字符串
  table.timestamps(true,true) //创建时间和更新时间
}).then(() => {
  console.log('创建成功')
})

